package com.example.teacher

import android.os.Bundle
import android.util.Log
import android.webkit.WebChromeClient
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.teacher.databinding.ActivityQRCodeBinding

/**
 * 进行二维码签到
 */
class QRCodeActivity : AppCompatActivity() {

    private lateinit var binding: ActivityQRCodeBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_q_r_code)


        //支持javascript
        binding.webviewQR.getSettings().setJavaScriptEnabled(true);
        // 设置可以支持缩放
//        binding.webviewQR.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
//        binding.webviewQR.getSettings().setBuiltInZoomControls(true);
        //扩大比例的缩放
        binding.webviewQR.getSettings().setUseWideViewPort(true);

        //设置默认比例25%
        binding.webviewQR.setInitialScale(25)

        //避免跳转到系统浏览器
        binding.webviewQR.webViewClient = WebViewClient()
        binding.webviewQR.webChromeClient = WebChromeClient()

//        binding.webviewQR.setwebviewQRClient(object :webviewQRClient() {
//
//            override fun shouldOverrideUrlLoading(view: webviewQR?, url: String?): Boolean {
//                view?.loadUrl(R.string.host1.toString()+"getImage")
//                return true
//            }
//        })
//        binding.webviewQR.loadUrl("http://www.taobao.com/")
        val stringExtra = intent.getStringExtra("QrData")
        Log.d("string", "$stringExtra")
        binding.webviewQR.loadUrl("${BaseUrl.URL}${BaseUrl.GET_QRCODE}?content=$stringExtra")
    }
}